package cn.lystudio.rohmtimeopwide_background_v11.controller.webApi;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaIgnore;
import cn.lystudio.rohmtimeopwide_background_v11.dtree.DTreeResponse;
import cn.lystudio.rohmtimeopwide_background_v11.entity.dto.DTree;
import cn.lystudio.rohmtimeopwide_background_v11.service.DTreeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@RestController
@SaCheckLogin
@RequestMapping("/webapi/machineOgztionDTree")
@Slf4j
public class MachineOgztionDTreeController {
    private DTreeService dTreeService;
    @Autowired
    @Lazy
    public void setDTreeService(DTreeService dTreeService) {
        this.dTreeService = dTreeService;
    }

    @GetMapping("/findAll")
    public DTreeResponse findAll(){
        return DTreeResponse.ofSuccessData(dTreeService.getAll(true)) ;
    }

    @GetMapping("/findAllSecDept")
    @SaIgnore
    public DTreeResponse findAllSecDept(){
        return DTreeResponse.ofSuccessData(dTreeService.getAllSecDept()) ;
    }


    @GetMapping("/findAll4dashboard")
    @SaIgnore
    public DTreeResponse findAll4dashboard(){
        //return null;
        return DTreeResponse.ofSuccessData(dTreeService.getAll(false)) ;
    }

    @GetMapping("/find4UsmBt")
    public DTreeResponse find4UsmBt(){
        return DTreeResponse.ofSuccessData(dTreeService.getAll4UsmBt()) ;
    }

    @GetMapping("/find4UsmZl")
    public DTreeResponse find4UsmZl(){
        return DTreeResponse.ofSuccessData(dTreeService.getAll4UsmZl()) ;
    }

    @GetMapping("/find4UsmCd")
    public DTreeResponse find4UsmCd(){
        return DTreeResponse.ofSuccessData(dTreeService.getAll4UsmCd()) ;
    }
}
